import React, { useEffect, useState } from 'react';
import {
    Button,
    Cascader,
    DatePicker,
    Form,
    Input,
    InputNumber,
    Radio,
    Select,
    Switch,
    TreeSelect,
} from 'antd';

type SizeType = Parameters<typeof Form>[0]['size'];

const Myform: React.FC = (props) => {
    const [componentSize, setComponentSize] = useState<SizeType | 'default'>('default');

    const onFormLayoutChange = ({ size }: { size: SizeType }) => {
        setComponentSize(size);
    };
    const [form] = Form.useForm();
    useEffect(() => {
        if (props.title == "详情") {
            form.setFieldsValue(props.itemobj)
        }
    }, [])
    return (
        <Form
            form={form}
            labelCol={{ span: 4 }}
            wrapperCol={{ span: 14 }}
            layout="horizontal"
            initialValues={{ size: componentSize }}
            onValuesChange={onFormLayoutChange}
            size={componentSize as SizeType}
            style={{ maxWidth: 600 }}
        >
            <Form.Item label="订单标题" name="title">
                <Input />
            </Form.Item>
            <Form.Item label="关联客户" name="address">
                <Input />
            </Form.Item>
            <Form.Item label="订单总金额" name="price">
                <Input />
            </Form.Item>
            <Form.Item label="审批类型" name="type">
                <Select>
                    <Select.Option value="1">完成审批</Select.Option>
                    <Select.Option value="2">等待审批</Select.Option>
                </Select>
            </Form.Item>
            <Form.Item label="创建人员" name="createPeople">
                <Input />
            </Form.Item>
            <Form.Item label="提交时间" name="createTime">
                <Input />
            </Form.Item>
            <Form.Item>
                <Button>保存</Button>
            </Form.Item>
        </Form>
    );
};

export default Myform;
